//
//  YAYIOrderDetailCell.m
//  YAYIDoctor
//
//  Created by hxp on 16/5/6.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIOrderDetailCell.h"

@implementation YAYIOrderDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}

-(void)createViews
{
    self.title = [UILabel new];
    self.title.font = [UIFont systemFontOfSize:font14];
    self.title.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.title];

    self.name = [UILabel new];
    self.name.textAlignment = NSTextAlignmentRight;
    self.name.font = [UIFont systemFontOfSize:font14];
    self.name.textColor = [UIColor lightGrayColor];
    self.name.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.name];
    
    self.icon = [UIImageView new];
    
    self.icon.image = [UIImage imageNamed:@"pay"];
    [self.contentView addSubview:self.icon];
    
    self.seprateLine = [UILabel new];
    self.seprateLine.backgroundColor = YAYIColor(0xdd, 0xdd, 0xdd);
    [self.contentView addSubview:self.seprateLine];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    if (self.section == 1 || self.section == 3 || self.section == 4) {
        [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(20));
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(200, 20));
//            make.height.mas_equalTo(20);
        }];
        [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).with.offset(-20);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(200, 20));
        }];
  
    }else if (self.section == 2) {
        [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).with.offset(16);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(30, 30));
        }];
       
        [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).with.offset(-20);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.height.mas_equalTo(20);
//            make.size.mas_equalTo(CGSizeMake(200, 20));
        }];
        
        [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.icon.mas_right).with.offset(25);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
//            make.size.mas_equalTo(CGSizeMake(200, 20));
            make.height.mas_equalTo(20);
            make.right.mas_equalTo(self.name.mas_left).offset(-10);
        }];
        
        [self.seprateLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(0));
            make.right.equalTo(@(0));
            make.top.mas_equalTo(self.contentView.mas_bottom).with.offset(0);
            make.height.equalTo(@(0.5));
        }];
        
    }
}


@end
